beta_ltm_rmse <- (beta_mat_truth - beta_mat_ltm)^2
x_ltm_rmse <- (x_mat_truth - x_mat_ltm)^2
#root and mean across columns
alpha_ltm_rmse<-(apply(alpha_ltm_rmse,2,mean))^.5
beta_ltm_rmse<-(apply(beta_ltm_rmse,2,mean))^.5
x_ltm_rmse<-(apply(x_ltm_rmse,2,mean))^.5
#return all sim objects
return(list(xm=xm, xs=xs, am=am, as=as, cJ=cJ, cN=cN,
ltmtime=ltmtime,emirttime=emirttime,
x_mat_truth=x_mat_truth,alpha_mat_truth=alpha_mat_truth,beta_mat_truth=beta_mat_truth,
alpha_mat_em=alpha_mat_em,alpha_mat_ltm=alpha_mat_ltm,beta_mat_em=beta_mat_em,beta_mat_ltm=beta_mat_ltm,
x_mat_em=x_mat_em,x_mat_ltm=x_mat_ltm,
alpha_em_rmse=alpha_em_rmse,beta_em_rmse=beta_em_rmse,x_em_rmse=x_em_rmse,
alpha_ltm_rmse = alpha_ltm_rmse, beta_ltm_rmse = beta_ltm_rmse, x_ltm_rmse = x_ltm_rmse))
}#closing bracket.
#!/usr/bin/env Rscript
### ########
### Packages
### ########
library("foreign")
library("ltm")
#only do this once.
#install_github("kosukeimai/emIRT", ref ="development")
library("emIRT")
### ####################
### Simulate True Params
### ####################
genData <- function(.N = 20,
.J = 100,
.D = 1,
scale = 1,
type="cumulative",
alpha_mu = 0,
alpha_sd = 10,
beta_mu = 0,
beta_sd = 10,
x_mu = 0,
x_sd = 1
) {
alpha <- matrix(rnorm(.J, alpha_mu, alpha_sd),
nrow = .J
)
beta <- matrix(##abs(rnorm(.D * .J, 0, 10)), # switch for unfolding vs. cumulative
if(type=="cumulative"){
print("Cumulative model used")
rnorm(.D * .J, beta_mu, beta_sd)
} else {
abs(rnorm(.D * .J, 0, 10))
print("Unfolding model used")
}
,
nrow = .J
)
x <- matrix(rnorm(.D * .N, x_mu, x_sd),
nrow = .N
)
eps <- matrix(rnorm(.N * .J, #stochastic component
sd = 1 * scale
),
nrow = .N
)
mu <- cbind(1, x) %*% t(cbind(alpha, beta))
ystar <- mu + eps
y <- (ystar > 0) * 1
return(list(alpha = alpha,
beta = beta,
x = x,
mu = mu,
ystar = ystar,
y = y,
scale = scale
)
)
}
############
#simulation code for comparing emIRT and ltm
############
run_sim<-function(xm, xs, am, as, cJ, cN){
#returns NA if model fails to fit for any reason
alpha_mat_truth <- beta_mat_truth <- alpha_mat_em <- beta_mat_em <- alpha_mat_ltm <- beta_mat_ltm <- matrix(ncol = length(xm), nrow = cJ)
x_mat_truth <-  x_mat_em <- x_mat_ltm <- matrix(ncol = length(xm), nrow = cN)
ltmtime<-emirttime<-matrix(ncol=1,nrow=length(xm))
for(i in seq(1,length(xm),1)){
dat <- genData(cN, cJ, scale = 10,type="cumulative", x_mu = xm[i], x_sd = xs[i],
alpha_mu = am[i], alpha_sd = as[i])
#true values
alpha_mat_truth[,i] <- dat$alpha
beta_mat_truth[,i] <- dat$beta
x_mat_truth[,i]<-dat$x
#emIRT
lP <- makePriors(nrow(dat$y),
ncol(dat$y),
1
)
lS <- getStarts(nrow(dat$y),
ncol(dat$y),
1
)
rcY <- convertRC(rollcall(dat$y))
ptm<-proc.time()[3]#Jon I added in capturing and storing processing time
mEMIRT <- tryCatch({
binIRT(.rc = rcY,
.starts = lS,
.priors = lP,
.D = 1
,.anchor_outcomes=TRUE
)
}, error = function(e){
return(NULL)
}, warning = function(w){
return(NULL)
}, finally = {
message("finished emIRT")
}
)
if(is.null(mEMIRT)){
beta_mat_em[,i] <- rep(NA, cJ)
alpha_mat_em[,i] <- rep(NA, cJ)
x_mat_em[,i] <- rep(NA, cN)
emirttime[i]<-NA
}else{
emirttime[i]<-proc.time()[3] - ptm
beta_mat_em[,i]<-mEMIRT$means$beta[,1]
alpha_mat_em[,i]<-mEMIRT$means$beta[,2]
x_mat_em[,i]<-mEMIRT$means$x[, 1]
}
#fit LTM
ptm<-proc.time()[3]
mLTM <- tryCatch({
ltm(dat$y ~ z1,
IRT.param = TRUE
)}, error = function(e){
return(NULL)
}, warning = function(w){
return(NULL)
}, finally = {
message("finished LTM")
}
)
if(is.null(mLTM)){
beta_mat_ltm[,i] <- rep(NA, cJ)
alpha_mat_ltm[,i] <- rep(NA, cJ)
x_mat_ltm[,i] <- rep(NA, cN)
ltmtime[i]<-NA
}else{
ltmtime[i]<-proc.time()[3] - ptm
beta_mat_ltm[,i] <- mLTM$coefficients[, 2]
alpha_mat_ltm[,i] <-mLTM$coefficients[, 1]
lLTMx <- factor.scores(mLTM,resp.patterns=dat$y)
x_mat_ltm[,i] <- lLTMx$score.dat$z1
}
}
#RMSE for EM
alpha_em_rmse<-(alpha_mat_truth-alpha_mat_em)^2
beta_em_rmse<-(beta_mat_truth-beta_mat_em)^2
x_em_rmse<-(x_mat_truth-x_mat_em)^2
#root and mean across columns
alpha_em_rmse<-(apply(alpha_em_rmse,2,mean))^.5
beta_em_rmse<-(apply(beta_em_rmse,2,mean))^.5
x_em_rmse<-(apply(x_em_rmse,2,mean))^.5
#RMSE for ltm
alpha_ltm_rmse <- (alpha_mat_truth - alpha_mat_ltm)^2
beta_ltm_rmse <- (beta_mat_truth - beta_mat_ltm)^2
x_ltm_rmse <- (x_mat_truth - x_mat_ltm)^2
#root and mean across columns
alpha_ltm_rmse<-(apply(alpha_ltm_rmse,2,mean))^.5
beta_ltm_rmse<-(apply(beta_ltm_rmse,2,mean))^.5
x_ltm_rmse<-(apply(x_ltm_rmse,2,mean))^.5
#return all sim objects
return(list(xm=xm, xs=xs, am=am, as=as, cJ=cJ, cN=cN,
ltmtime=ltmtime,emirttime=emirttime,
x_mat_truth=x_mat_truth,alpha_mat_truth=alpha_mat_truth,beta_mat_truth=beta_mat_truth,
alpha_mat_em=alpha_mat_em,alpha_mat_ltm=alpha_mat_ltm,beta_mat_em=beta_mat_em,beta_mat_ltm=beta_mat_ltm,
x_mat_em=x_mat_em,x_mat_ltm=x_mat_ltm,
alpha_em_rmse=alpha_em_rmse,beta_em_rmse=beta_em_rmse,x_em_rmse=x_em_rmse,
alpha_ltm_rmse = alpha_ltm_rmse, beta_ltm_rmse = beta_ltm_rmse, x_ltm_rmse = x_ltm_rmse))
}#closing bracket.
### ###################
### Simulation Settings
### ###################
cN <- 300  # number of students
cJ <- 50   # number of questions
xm = c(0,-20, -20, 0)  # mean used to calculate student ability distribution
xs = c(1,1, 1, 1)      # sd of student ability distribution
am = c(0,-20, 0, -20)  # mean of difficulty distribution
as = c(1,1,1,1)        # sd of difficulty distribution
xm = c(0)  # mean used to calculate student ability distribution
xs = c(1)      # sd of student ability distribution
am = c(0)  # mean of difficulty distribution
as = c(1)        # sd of difficulty distribution
# Student and Question performance distributions:
# xm = 0, xs = 1; am = 0, as = 1: student & question stable
# xm = 0, xs = 1; am = -20, as = 1: student & question skewed (positive tail, most mass near 0)
# xm = -20, xs = 1; am = -20, as = 1: student somewhat skewed (centered below .5), question bimodal (more mass at zero, most of the rest at 1)
# xm = -20, xs = 1; am = 0, as = 1: student relatively stable, question bimodal (fairly even between 0 and 1)
#test one simulation run:
f<-run_sim(xm, xs, am, as, cJ, cN)
str(f)
#####
#multiple sims for a given set of params
#####
results<-list()
sims<-20
for(i in 1:sims){
results[[i]]<-  run_sim(xm, xs, am, as, cJ, cN)
}
#store results by model type
n<-c("rmse.alpha","rmse.beta","rmse.x","xm","am", "as","xs", "cJ", "cN","time")
rmse.em<-rmse.ltm<-as.data.frame(matrix(nrow = length(xm)*sims, ncol = length(n)))
names(rmse.em)<-names(rmse.ltm)<-n
r <- 1
for(i in 1:sims){
for(j in 1:length(xm)){
h<-j
rmse.em[r,1] <- results[[i]]$alpha_em_rmse[j]
rmse.ltm[r,1] <- results[[i]]$alpha_ltm_rmse[j]
rmse.em[r,2] <- results[[i]]$beta_em_rmse[j]
rmse.ltm[r,2] <- results[[i]]$beta_ltm_rmse[j]
rmse.em[r,3] <- results[[i]]$x_em_rmse[j]
rmse.ltm[r,3] <- results[[i]]$x_ltm_rmse[j]
rmse.em[r,4] <- rmse.ltm[r,4] <- results[[i]]$xm[j]
rmse.em[r,5] <- rmse.ltm[r,5] <- results[[i]]$xs[j]
rmse.em[r,6] <- rmse.ltm[r,6] <-results[[i]]$am[j]
rmse.em[r,7] <- rmse.ltm[r,7] <-results[[i]]$as[j]
rmse.em[r,8] <- rmse.ltm[r,8] <- results[[i]]$cJ
rmse.em[r,9] <- rmse.ltm[r,9] <- results[[i]]$cN
rmse.em[r,10] <- rmse.ltm[r,10] <- results[[i]]$emirttime[j]
r <- r+1
}
}
rmse.em
str(f)
f<-run_sim(xm, xs, am, as, cJ, cN)
str(f)
library("foreign")
library("ltm")
#only do this once.
install_github("kosukeimai/emIRT", ref ="development")
library("emIRT")
#!/usr/bin/env Rscript
### ########
### Packages
### ########
library("foreign")
library("ltm")
library("devtools")
#only do this once.
install_github("kosukeimai/emIRT", ref ="development")
library("emIRT")
28323+1767
install.packages("C:/Users/dtingley/Dropbox/fakeData/fakeData_1.0.tar.gz", repos = NULL, type = "source")
library(fakeData)
shiny::runApp('C:/Users/dtingley/Dropbox/TingleyPolit/timeseries_working')
shiny::runApp('C:/Users/dtingley/Dropbox/TingleyPolit/Canvas/Timeseries')
122*600
25/19
170*1.3
library(stm)
install.packages(c("abind", "broom", "caret", "crayon", "curl", "devtools", "DiagrammeR", "dplyr", "ggvis", "googlesheets", "googleVis", "httr", "jsonlite", "lazyeval", "mgcv", "mime", "networkD3", "plyr", "proxy", "psych", "purrr", "quantreg", "Rcpp", "RcppArmadillo", "rmarkdown", "rstudioapi", "slam", "survival", "tidyr", "V8", "visNetwork", "withr", "xml2"))
install.packages("curl")
install.packages("Rcpp")
install.packages("C:/Users/dtingley/Dropbox/SubgroupTemp/package/sparsereg_1.3.tar.gz", repos = NULL, type = "source")
library(mediation)
install.packages("mediation")
library(mediation)
?mediate
causal_cont(depress2, treat, econ_hard,mediator=job_seek ,data=jobs)
library(sparsereg)
N<-1000
e1 <- rnorm(N)
e2 <- rnorm(N)
ALPHA.2 <- BETA.2*T <- ETA.2 <- GAMMA <- 1
M <- ALPHA.2 + BETA.2*T + ETA.2*X.1 + e1
Y <-  ALPHA.3 + BETA.3*T + GAMMA*M + ETA.3*X.1+ e2
N<-1000
e1 <- rnorm(N)
e2 <- rnorm(N)
ALPHA.2 <- BETA.2  <- ETA.2 <- GAMMA <- 1
X.1 <- rnorm(N)#fix values of X and T
T <- round(runif(N), 0)
M <- ALPHA.2 + BETA.2*T + ETA.2*X.1 + e1
Y <-  ALPHA.3 + BETA.3*T + GAMMA*M + ETA.3*X.1+ e2
N<-1000
e1 <- rnorm(N)
e2 <- rnorm(N)
ALPHA.3 <- ALPHA.2 <- BETA.2  <- ETA.2 <- GAMMA <- 1
X.1 <- rnorm(N)#fix values of X and T
T <- round(runif(N), 0)
M <- ALPHA.2 + BETA.2*T + ETA.2*X.1 + e1
Y <-  ALPHA.3 + BETA.3*T + GAMMA*M + ETA.3*X.1+ e2
N<-1000
e1 <- rnorm(N)
e2 <- rnorm(N)
ALPHA.3 <- ALPHA.2 <- BETA.2 <- BETA.3  <- ETA.2 <- GAMMA <- 1
X.1 <- rnorm(N)#fix values of X and T
T <- round(runif(N), 0)
M <- ALPHA.2 + BETA.2*T + ETA.2*X.1 + e1
Y <-  ALPHA.3 + BETA.3*T + GAMMA*M + ETA.3*X.1+ e2
N<-1000
e1 <- rnorm(N)
e2 <- rnorm(N)
ALPHA.3 <- ALPHA.2 <- BETA.2 <- BETA.3  <- ETA.3 <- ETA.2 <- GAMMA <- 1
X.1 <- rnorm(N)#fix values of X and T
T <- round(runif(N), 0)
M <- ALPHA.2 + BETA.2*T + ETA.2*X.1 + e1
Y <-  ALPHA.3 + BETA.3*T + GAMMA*M + ETA.3*X.1+ e2
model.m <- lm(M ~ T+X.1)
model.y <- lm(Y ~ T+M+X.1)
f<-mediate(model.m,model.y)
install.packages("C:/Users/dtingley/Dropbox/SubgroupTemp/package/sparsereg_1.3.tar.gz", repos = NULL, type = "source")
f<-mediate(model.m,model.y,treat="T",mediate="M")
summary(model.m)
f<-mediate(model.m,model.y,treat="T",mediator="M")
summary(f)
install.packages("C:/Users/dtingley/Dropbox/SubgroupTemp/package/sparsereg_1.3.tar.gz", repos = NULL, type = "source")
library(sparsereg)
causal_cont(Y, T, X.1,mediator=M )
causal_cont(Y, T, X.1, M )
?causal_cont
M <- ALPHA.2 + BETA.2*T + ETA.2*X.1 + T*X.1 + e1
Y <-  ALPHA.3 + BETA.3*T + GAMMA*M + ETA.3*X.1 + T*X.1 + e2
f<-mediate(model.m,model.y,treat="T",mediator="M")
causal_cont(Y, T, X.1, M )
2/9
2.2/9
2.24/9
2.25/9
174000*1.03
174000*1.03/4
174000*1.03/4*.69
174000*1.03/4*.69 + 174000*1.03/4
23582*.55+23582
75000*1.2*1.69
50/60
11/12
174000*1.025
174000*1.025*1.025
174000*1.025*1.025*1.025
174000*1.025*1.025*1.025*1.025
220*25
install.packages("futile.logger")
install.packages("rworldmap")
install.packages("rworldxtra")
install.packages("VennDiagram")
library(mediation)
?mediate
data(jobs)
####################################################
# Example 1: Linear Outcome and Mediator Models
####################################################
b <- lm(job_seek ~ treat + econ_hard + sex + age, data=jobs)
c <- lm(depress2 ~ treat + job_seek + econ_hard + sex + age, data=jobs)
# Estimation via quasi-Bayesian approximation
contcont <- mediate(b, c, sims=50, treat="treat", mediator="job_seek")
str(contcont)
contcont$d.avg.p
summary(contcont)
mediate
data(jobs)
####################################################
# Example 1: Linear Outcome and Mediator Models
####################################################
b <- lm(job_seek ~ treat + econ_hard + sex + age, data=jobs)
c <- lm(depress2 ~ treat + job_seek + econ_hard + sex + age, data=jobs)
# Estimation via quasi-Bayesian approximation
contcont <- mediate(b, c, sims=1000, treat="treat", mediator="job_seek")
contcont$d.avg.p
install.packages("stmgui")
library(stmgui)
runStmGui()
install.packages("quantmod")
install.packages("highcharter")
library(devtools)
install_github("bstewart/stm",dependencies=TRUE)
29.99+65.27+65.27
160.53*.8
5.5*22
10*22
install.packages(c("acepack", "arm", "BH", "broom", "car", "caret", "cellranger", "chron", "cluster", "coda", "codetools", "colorspace", "colourpicker", "countrycode", "curl", "DBI", "DiagrammeR", "digest", "dygraphs", "emIRT", "evaluate", "expm", "fields", "flexdashboard", "foreign", "git2r", "googleVis", "highcharter", "Hmisc", "htmlwidgets", "irlba", "janeaustenr", "jsonlite", "knitr", "lattice", "lavaan", "leaflet", "lmtest", "loo", "lubridate", "maps", "maptools", "Matrix", "MCMCpack", "mgcv", "mnormt", "msm", "mvtnorm", "networkD3", "nlme", "NLP", "openssl", "pbkrtest", "plm", "plotly", "psych", "quantreg", "R6", "Rcpp", "RcppEigen", "readr", "reshape", "reshape2", "rgdal", "rmarkdown", "rsconnect", "sem", "shiny", "shinydashboard", "shinyjs", "shinystan", "shinythemes", "sp", "SparseM", "StanHeaders", "stm", "stringi", "survey", "survival", "testit", "tibble", "tidyr", "tidytext", "tm", "tokenizers", "topicmodels", "V8", "VGAM", "viridis", "viridisLite", "visNetwork", "XML", "xml2", "zoo"))
rm(list=ls())
library("cjoint")
#US Conjoint
load("C:/Users/dtingley/Dropbox/M&A - Conjoint Experiment/data/replication/USConjoint.RData")
results <- amce(cj_response ~  Reciprocity+Country + Owner + Natsec + Firmsize + Distress , data=use, cluster=TRUE, respondent.id="id", design="uniform")
summary(results)
theme_bw_new <- function(base_size = 11, base_family = ""){
theme_bw(base_size = base_size, base_family = base_family) %+replace%
theme(axis.text.x = element_text(size = base_size*.9, colour = "black",  hjust = .5 , vjust=1),
axis.text.y = element_text(size = base_size, colour = "black", hjust = 0 , vjust=.5 ),
axis.ticks = element_line(colour = "grey50"),
axis.title.y =  element_text(size = base_size,angle=90,vjust=.01,hjust=.1),
plot.title = element_text(face = "bold"),
legend.position = "none")
}
# Plot results
#pdf("../../results/USBasicConjointResults.pdf", width=14)
plot(results, xlab="Change in Pr(US should block acquisition)",
xlim=c(-.25,.25), breaks=c(-.4,-.2,0,.2,.4),
labels=c("-.4","-.2","0",".2", ".4"), text.size=11, plot.theme=theme_bw_new(), colors="black"
)
#dev.off()
rm(list=ls())
library("cjoint")
#US Conjoint
load("C:/Users/dtingley/Dropbox/M&A - Conjoint Experiment/data/replication/USConjoint.RData")
results <- amce(cj_response ~  Reciprocity+Country + Owner + Natsec + Firmsize + Distress , data=use, cluster=TRUE, respondent.id="id", design="uniform")
summary(results)
theme_bw_new <- function(base_size = 11, base_family = ""){
theme_bw(base_size = base_size, base_family = base_family) %+replace%
theme(axis.text.x = element_text(size = base_size*.9, colour = "black",  hjust = .5 , vjust=1),
axis.text.y = element_text(size = base_size, colour = "black", hjust = 0 , vjust=.5 ),
axis.ticks = element_line(colour = "grey50"),
axis.title.y =  element_text(size = base_size,angle=90,vjust=.01,hjust=.1),
plot.title = element_text(face = "bold"),
legend.position = "none")
}
# Plot results
#pdf("../../results/USBasicConjointResults.pdf", width=14)
plot(results, xlab="Change in Pr(US should block acquisition)",
xlim=c(-.25,.25), breaks=c(-.4,-.2,0,.2,.4),
labels=c("-.4","-.2","0",".2", ".4"), text.size=11, plot.theme=theme_bw_new(), colors="black"
)
#dev.off()
#China Conjoint
load("C:/Users/dtingley/Dropbox/M&A - Conjoint Experiment/data/replication/ChinaConjoint.RData")
# Run AMCE estimator - this calls the main amce() function in the cjoint package
results <- amce(cj_response.n ~  Ownership + Firmsize + Distress +Reciprocity, data=use, cluster=TRUE, respondent.id="id", design="uniform")
summary(results)
theme_bw_new <- function(base_size = 11, base_family = ""){
theme_bw(base_size = base_size, base_family = base_family) %+replace%
theme(axis.text.x = element_text(size = base_size*.9, colour = "black",  hjust = .5 , vjust=1),
axis.text.y = element_text(size = base_size, colour = "black", hjust = 0 , vjust=.5 ),
axis.ticks = element_line(colour = "grey50"),
axis.title.y =  element_text(size = base_size,angle=90,vjust=.01,hjust=.1),
plot.title = element_text(face = "bold"),
legend.position = "none")
}
# Plot results
setwd("../../results")
#pdf("ChinaMnAConjoint.pdf", width=10)
plot(results, xlab="Change in Pr(China should block acquisition)",
xlim=c(-.25,.25), breaks=c(-.4,-.2,0,.2,.4),
labels=c("-.4","-.2","0",".2", ".4"), text.size=11, plot.theme=theme_bw_new(), colors="black"
)
#dev.off()
rm(list=ls())
library("cjoint")
#US Conjoint
load("C:/Users/dtingley/Dropbox/M&A - Conjoint Experiment/data/replication/USConjoint.RData")
results <- amce(cj_response ~  Reciprocity+Country + Owner + Natsec + Firmsize + Distress , data=use, cluster=TRUE, respondent.id="id", design="uniform")
summary(results)
theme_bw_new <- function(base_size = 11, base_family = ""){
theme_bw(base_size = base_size, base_family = base_family) %+replace%
theme(axis.text.x = element_text(size = base_size*.9, colour = "black",  hjust = .5 , vjust=1),
axis.text.y = element_text(size = base_size, colour = "black", hjust = 0 , vjust=.5 ),
axis.ticks = element_line(colour = "grey50"),
axis.title.y =  element_text(size = base_size,angle=90,vjust=.01,hjust=.1),
plot.title = element_text(face = "bold"),
legend.position = "none")
}
# Plot results
pdf("../finalgraphs/USBasicConjointResults.pdf", width=14)
plot(results, xlab="Change in Pr(US should block acquisition)",
xlim=c(-.25,.25), breaks=c(-.4,-.2,0,.2,.4),
labels=c("-.4","-.2","0",".2", ".4"), text.size=11, plot.theme=theme_bw_new(), colors="black"
)
dev.off()
getwd()
rm(list=ls())
library("cjoint")
#US Conjoint
setwd("C:/Users/dtingley/Dropbox/M&A - Conjoint Experiment/data/replication/")
load("USConjoint.RData")
results <- amce(cj_response ~  Reciprocity+Country + Owner + Natsec + Firmsize + Distress , data=use, cluster=TRUE, respondent.id="id", design="uniform")
summary(results)
theme_bw_new <- function(base_size = 11, base_family = ""){
theme_bw(base_size = base_size, base_family = base_family) %+replace%
theme(axis.text.x = element_text(size = base_size*.9, colour = "black",  hjust = .5 , vjust=1),
axis.text.y = element_text(size = base_size, colour = "black", hjust = 0 , vjust=.5 ),
axis.ticks = element_line(colour = "grey50"),
axis.title.y =  element_text(size = base_size,angle=90,vjust=.01,hjust=.1),
plot.title = element_text(face = "bold"),
legend.position = "none")
}
# Plot results
pdf("../finalgraphs/USBasicConjointResults.pdf", width=14)
plot(results, xlab="Change in Pr(US should block acquisition)",
xlim=c(-.25,.25), breaks=c(-.4,-.2,0,.2,.4),
labels=c("-.4","-.2","0",".2", ".4"), text.size=11, plot.theme=theme_bw_new(), colors="black"
)
dev.off()
#China Conjoint
load("C:/Users/dtingley/Dropbox/M&A - Conjoint Experiment/data/replication/ChinaConjoint.RData")
# Run AMCE estimator - this calls the main amce() function in the cjoint package
results <- amce(cj_response.n ~  Ownership + Firmsize + Distress +Reciprocity, data=use, cluster=TRUE, respondent.id="id", design="uniform")
summary(results)
theme_bw_new <- function(base_size = 11, base_family = ""){
theme_bw(base_size = base_size, base_family = base_family) %+replace%
theme(axis.text.x = element_text(size = base_size*.9, colour = "black",  hjust = .5 , vjust=1),
axis.text.y = element_text(size = base_size, colour = "black", hjust = 0 , vjust=.5 ),
axis.ticks = element_line(colour = "grey50"),
axis.title.y =  element_text(size = base_size,angle=90,vjust=.01,hjust=.1),
plot.title = element_text(face = "bold"),
legend.position = "none")
}
# Plot results
pdf("../finalgraphs/ChinaMnAConjoint.pdf", width=10)
plot(results, xlab="Change in Pr(China should block acquisition)",
xlim=c(-.25,.25), breaks=c(-.4,-.2,0,.2,.4),
labels=c("-.4","-.2","0",".2", ".4"), text.size=11, plot.theme=theme_bw_new(), colors="black"
)
dev.off()
